#ifndef ASTAR_APPLICATION_H
#define ASTAR_APPLICATION_H

#include <windows.h>
#include <list>

struct Node;
struct Box;

class Bitmap;

class AStarApplication
{
public:
	AStarApplication(HINSTANCE _hInstance);
	~AStarApplication();

	void OnGameInitialize();
	void OnGameStart(HWND _hwnd);
	void OnGameEnd();
	void OnGameActivate(HWND _hwnd);
	void OnGameDeactivate(HWND _hwnd);
	void OnGameUpdate(HWND _hwnd);
	void OnGamePaint(HDC _hdc);
	void OnHandleKeys(HWND _hwnd);
	void OnMouseButtonDown(int _x, int _y, bool _left);
	void OnMouseButtonUp(int _x, int _y, bool _left);
	void OnMouseMove(int _x, int _y);

private:
	Node* SelectedNode(int _x, int _y);
	Node* GetNodeByID(unsigned int _ID);

	void RepaintMap(bool _keep);

	void Binarize(const char* _filename);
	void Unbinarize(const char* _filename);

	HINSTANCE hInstance;
	HWND m_hwnd;
	HDC m_hDC;
	Bitmap* m_background;
	Bitmap* m_totalBackground;

	typedef std::list<Node*> NODE_CONTAINER;
	typedef NODE_CONTAINER::iterator NODE_IT;
	typedef NODE_CONTAINER::const_iterator NODE_CIT;
	NODE_CONTAINER m_nodes;

	typedef std::list<Box*> BOX_CONTAINER;
	typedef BOX_CONTAINER::iterator BOX_IT;
	typedef BOX_CONTAINER::const_iterator BOX_CIT;
	BOX_CONTAINER m_boxes;

	Node* m_selected;
	unsigned int m_nextID;
	int m_prevX, m_prevY;
	bool m_mouseDown;
};

#endif
